package com.tobby.camelinaction.service;

import javax.sql.DataSource;

import org.apache.camel.spi.Registry;
import org.springframework.jdbc.core.JdbcTemplate;

import com.tobby.camelinaction.InputOrder;

public class OrderDao {

	public void insertOrder(InputOrder order, Registry registry) {
		DataSource dataSource = registry.lookupByNameAndType("myDataSource",
				DataSource.class);
		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

		Object[] args = new Object[] { order.getCustomerId(), order.getRefNo(),
				order.getPartId(), order.getAmount() };
		jdbcTemplate.update(
				"insert into riders_order (customer_id, ref_no, part_id, amount) values (?, ?, ?, ?)",
				args);
	}

}
